local sk__xingshen = fk.CreateSkill {

  name = "sk__xingshen",

  tags = { Skill.Compulsory, },

}



sk__xingshen:addEffect(fk.Damaged, {
  anim_type = "masochism",
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    for i = 1, data.damage do
      if self.cancel_cost or not player:hasSkill(sk__xingshen.name) then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(2, sk__xingshen.name)
    if not player.dead and player:getMark("@@sk__xingshen") == 0 then
      if player:isWounded() then
        room:recover{
          who = player,
          num = 1,
          recoverBy = player,
          skillName = sk__xingshen.name,
        }
      end
      if not player.dead then
        room:setPlayerMark(player, "@@sk__xingshen", 1)
      end
    end
  end,
})
sk__xingshen:addEffect(fk.TurnEnd, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@sk__xingshen") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@sk__xingshen", 0)
  end,
})

return sk__xingshen